<template>
	<view class="content">

		<view class="top">
			<image :src="activity.img"></image>
		</view>

		<view class="middle">
			<view class="middle_for" v-for="(item, idx) in list">
				<view class="middle_imgs" @click="to_exhibition(item.id, item.note)">
					<image :src="item.imgs" mode=""></image>
				</view>
			</view>
		</view>

		<view class="spring_festival_gala" @click="to_exhibition(springFestivalGala.id, springFestivalGala.note)">
			<image :src="springFestivalGala.imgs" mode=""></image>
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				user: null,
				activity: null,
				list: [],
				springFestivalGala: {},
			}
		},
		onLoad(opt) {
			uni.showLoading({
				title: '加载中...'
			});
			if (opt.Bearer) {
				uni.setStorageSync("Bearer", opt.Bearer);
				this.bearer();
			} else if (opt.code) {
				this.loginx(code);
			} else {
				this.user = uni.getStorageSync("member");
				this.get_list();
			}
		},
		methods: {
			bearer() {
				let self = this
				this.$boya.NGet("/app/auth/user", null, function(res) {
					console.log("bearer: ", res);
					self.user = res.data.member;
					uni.setStorageSync("member", res.data.member);
					uni.showToast({
						title: '登录中...',
						duration: 1000,
						icon: 'loading'
					})
					self.get_list();
				}, err => {
					console.log('bearerErr: ', err);
					uni.showToast({
						title: '登录失败,请重试',
						duration: 2000,
						icon: 'error'
					});
				}, false, false)
			},
			loginx(code) {
				let self = this
				console.log('code: ', code);
				self.$boya.NPost('/tpi/loginx', {
					code: code
				}, function(res) {
					console.log("loginx", res);
					if (res.code == 200) {
						self.user = res.data.user;
						uni.setStorageSync("member", res.data.user);
						uni.showToast({
							title: '登录中...',
							duration: 1000,
							icon: 'loading'
						})
						self.get_list();
					} else {
						uni.showToast({
							title: '登录失败,请重试',
							duration: 2000,
							icon: 'error'
						});
					}
				}, false)
			},
			get_list() {
				let self = this
				self.$boya.Request({
					url: '/activity/article',
					data: {
						type: 25,
					}
				}, function(res) {
					console.log('listRes: ', res.data);
					uni.hideLoading();
					self.activity = res.data.activity
					let data = res.data.data
					for (var i = 0; i < data.length; i++) {
						if (data[i].imgs) {
							let img = data[i].imgs.substring(2, data[i].imgs.length - 2);
							data[i].imgs = img
						}
						if (data[i].type == 1) {
							self.list.push(data[i])
						} else if (data[i].type == 2) {
							self.springFestivalGala = data[i]
						}
					}
					// console.log('list: ', self.list);
					// console.log('springFestivalGala: ', self.springFestivalGala);
				}, false)
			},
			to_exhibition(id, note) {
				uni.navigateTo({
					url: '/pages/activities/newYear/NY2025/exhibition?id=' + id + '&note=' + note
				})
			},
		},
	}
</script>

<style>
	.content {
		width: 100vw;
		min-height: 100vh;
		padding-bottom: 100rpx;
		background: linear-gradient(to bottom, #B70916, #B70916, #FB4651);
	}

	.top {
		width: 100vw;
		height: 490rpx;
	}

	.top>image {
		width: 100%;
		height: 100%;
	}

	.middle {
		width: 100vw;
		margin: 0 auto;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		position: relative;
		z-index: 99;
		margin-top: -30rpx;
	}

	.middle_imgs {
		width: 50vw;
		height: 440rpx;
		margin-top: -10rpx;
	}

	.middle_imgs>image {
		width: 100%;
		height: 100%;
	}

	.spring_festival_gala {
		width: 100vw;
		height: 300rpx;
	}

	.spring_festival_gala>image {
		width: 100%;
		height: 100%;
	}
</style>